package demo1;

import java.util.Locale;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-07-01
 * Time: 10:55
 */
public class Test01 {
    public static void main(String[] args) {
        String s1 = "";
        System.out.println(s1);
    }
    public static String add(String n1,String n2) {
        int a = n1.length() - 1;
        int b = n2.length() - 1;
        int add = 0;
        StringBuffer str =new StringBuffer();
        while(a >= 0 || b >= 0 || add != 0) {
            int x = 0;
            int y = 0;
            if(a >= 0) {
                x = n1.charAt(a) - '0';
            }else {
                x = 0;
            }
            if(b >= 0) {
                y = n2.charAt(b) - '0';
            }else {
                y = 0;
            }
            int tmp = x + y + add;
            str.append(tmp % 10);
            add = tmp / 10;
            a--;
            b--;
        }
        str.reverse();
        return str.toString();
    }
    public static void main5(String[] args) {
        String n1 = "123";
        String n2 = "89";
        System.out.println(add(n1,n2));
    }
    public static void main4(String[] args) {
        String n1 = "11";
        String n2 = "22";
        String n3 = n1 + n2;
        System.out.println(n3);
    }
    public static boolean isNumber(char c1) {
        if(Character.isLetterOrDigit(c1)) {
            return true;
        }
        return false;
    }
    public static boolean isStr(String s1) {
        s1 = s1.toLowerCase();
        int left = 0;
        int right = s1.length() - 1;
        while(left < right) {
            while(left < right && !isNumber(s1.charAt(left))) {
                left++;
            }
            while(left < right && !isNumber(s1.charAt(right))) {
                right--;
            }
            if(s1.charAt(left) == s1.charAt(right)) {
                left++;
                right--;
            }else {
                return false;
            }
        }
        return true;
    }
    public static void main3(String[] args) {
        String s1 = "A man, a plan, a canal: Panama";
        System.out.println(isStr(s1));
    }
    //方法1
    public static int len1(String s1) {
        int a = s1.lastIndexOf(" ");
        if(a == -1) {
            return s1.length();
        }
        return s1.substring(a + 1).length();
    }
    //方法2
    public static int len2(String s2) {
        String[] s1 = s2.split(" ");
        return s1[s1.length - 1].length();
    }
    public static void main2(String[] args) {
        String s1 = "hello world";
        System.out.println(len1(s1));
        System.out.println(len2(s1));
    }
    public static int find(String s1) {
        int[] arr = new int[26];
        for (int i = 0; i < s1.length(); i++) {
            arr[s1.charAt(i) - 97]++;
        }
        for (int i = 0; i < s1.length(); i++) {
            if(arr[s1.charAt(i) - 97] == 1) {
                return i;
            }
        }
        return -1;
    }
    public static void main1(String[] args) {
        String s1 = "baccdd";
        System.out.println(find(s1));
    }
}
